#ifndef	_MH_WINAPP_H_
#define	_MH_WINAPP_H_

#include <mh/app.hpp>
#include <mh/hid.hpp>
#include <mh/resource.hpp>
#include <mh/audio.hpp>
#include <mh/util.hpp>
#include <mh/timer.hpp>

#include <windows.h>
#include <tchar.h>

namespace Mh
{
	// 윈도우 애플리케이션 클래스... 나중에 좀 고쳐야할듯.
	class MH_CLASS WinApp : public App
	{
	public:
		WinApp( HINSTANCE hInstance, LPTSTR lpCmdLine, int nCmdShow );
		virtual ~WinApp();

		virtual bool	initialize( LPCTSTR title, uint width, uint height );
		virtual void	finalize();

		virtual	bool	on_resize( int width, int height );

		/*!
		 *	\brief	루프 실행
		 *	\return	종료 코드
		 */
		virtual	int		run();

		virtual LRESULT window_proc(HWND hHwnd, UINT message, WPARAM wParam, LPARAM lParam);

		virtual void on_mouse_move(WPARAM button_state, int x, int y);
		virtual void on_mouse_up(WPARAM button_state, int x, int y);
		virtual void on_mouse_down(WPARAM button_state, int x, int y);
		virtual void on_mouse_doubleclick(WPARAM button_state, int x, int y);
		virtual void on_mouse_wheel(short wheel_delta, WORD button_state, int x, int y);

		HID::Manager*	get_hid_manager()		{ return m_hid; }

		::HINSTANCE		get_instance_handle() const	{ return m_instance; }
		::HWND			get_window_handle() const	{ return m_hwnd; }

		bool is_paused() const { return m_paused; }
		bool is_minimized() const { return m_minimized; }
		bool is_maximized() const { return m_maximized; }

	protected:
		Timer* get_timer()				{ return m_timer; }
		const Timer* get_timer() const	{ return m_timer; }

	private:
		bool			get_system_info() const;
		bool			create_window( LPCTSTR title, uint width, uint height );

	private:
		HINSTANCE			m_instance;
		HWND				m_hwnd;
		
		HID::Manager*		m_hid;
		Resource::Manager*	m_resource;

		bool				m_paused;
		bool				m_minimized;
		bool				m_maximized;
		bool				m_resizing;

		Timer*				m_timer;
	};
}

#endif	// #ifndef	_MH_WINAPP_H_